<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>工单列表</title>
		<link rel="stylesheet" href="../../js/plugins/layui-v2.4.5/layui/css/layui.css" />
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/list.css" />
		<style>
			.layui-progress{margin-top: 11px;}
		</style>
	</head>
	<body>
		<div class="container">
			<div class="layui-form search-container">
				<div class="layui-inline">
					<label class="layui-form-label">工单标题</label>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" autocomplete="off" placeholder="请输入" id="titleInput">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">受理人</label>
					<div class="layui-input-inline">
						<select name="type" lay-verify="" >
						  <option value="">请选择</option>
						  <option value="0">信息中心</option>
						  <option value="其它">其它</option>
						</select> 
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">工单状态</label>
					<div class="layui-input-inline">
						<select name="type" lay-verify="" >
						  <option value="">请选择</option>
						  <option value="0">在用</option>
						  <option value="1">待废</option>
						</select> 
					</div>
				</div>
				<a href="javascript:;" class="layui-btn layui-btn-sm"><i class="layui-icon layui-icon-search"></i>查询</a>
			</div>
			<div class="btn-container"><a href="javascript:;" id="addBtn" class="layui-btn layui-btn-sm">添加</a></div>
			<table id="list" lay-filter="list"></table>
		</div>
		<script src="../../js/jquery-3.3.1.min.js"></script>
		<script src="../../js/plugins/layui-v2.4.5/layui/layui.js"></script>
		<script src="../../js/common.js"></script>
		<script>
			var data = [
						{id:1,num:'WL20190425012',title:'电脑开不了机',progress:40,addr:'博大901',type:'网络',time:'2019.4.11 11:29',state:1,creater:'李敏',receiver:'李艾'}
					];
			layui.use(['table','element'],function(){
				var table = layui.table,element = layui.element;
				//第一个实例
				  table.render({
					elem: '#list'
					,height: '300'
					,url: '' //数据接口
					,page: true //开启分页
					,cols: [[ //表头
					  {field: 'xh', title: '序号', width:80,align:'center'
					  ,templet:function(d){
						  return d.LAY_INDEX;
					  }}
					  ,{field: 'num', title: '工单编号',align:'center'}
					  ,{field: 'title', title: '工单标题', align:'center'}
					  ,{field: 'type', title: '工单类型', align:'center'} 
					  ,{field: 'progress', title: '进度', align:'center'
					  ,templet:function(d){
						  return `<div class="layui-progress">
							  <div class="layui-progress-bar" lay-percent="${d.progress}%"></div>
							</div>`
					  }}
					  ,{field: 'receiver', title: '受理人',align:'center'}
					  ,{field: 'state', title: '工单状态', align:'center'
					  ,templet:function(d){
						var arr = ['未分配','处理中','已处理'];
						var colors = ['layui-btn layui-btn-primary layui-btn-xs','layui-btn layui-btn-warm layui-btn-xs','layui-btn layui-btn-normal layui-btn-xs']
						return `<span class="${colors[d.state]}">${arr[d.state]}</span>`
					  }}
					  ,{field: 'addr', title: '位置', align:'center'}
					  ,{field: 'creater', title: '报修人', align:'center'}
					  ,{field: 'time', title: '保修时间', align:'center'}
					  ,{field: 'opt', title: '操作', width: 160,align:'center'
					  ,templet:function(d){
						  return `<a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs" onclick="edit(${d.id},event)"><i class="layui-icon layui-icon-edit"></i>编辑</a>
						  &nbsp;<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon layui-icon-delete"></i>删除</a>`
					  }}
					]]
					,data: data
					,done: function(res, curr, count){
						element.render('progress');
					}
				  });
				  table.on('row(list)',function(obj){
					openLayer_parent('order_detail.html','工单详情','800px','550px');
				  })
			})
			$(function(){
				$("#addBtn").click(function(){
					top.tabAdd('工单新增','order_add','pages/order/order_add.html',true,true);
					
				})
			})
			function edit(id,event){
				console.log("编辑");
				event.stopPropagation();
			}
			
		</script>
	</body>
</html>
